package test.examation;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class 网易游戏 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();

        char[] s = String.valueOf(b).toCharArray();
        HashMap<Integer,Character> map=new HashMap<>();
        for (int i = 1; i <= s.length; i++) {
            map.put(i,s[i-1]);
        }

        for(int i=a+1;i<=b;i++){
            char[] chars = String.valueOf(i).toCharArray();
            for (int j = 0; j < chars.length; j++) {
                if(!map.containsValue(chars[j])) break;
                if(j==chars.length-1){
                    System.out.println(i);
                    return;
                }
            }
        }
        System.out.println(-1);


    }
}
